package javax.microedition.io;

import android.util.Log;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Properties;

public class Connector {
  private static final String PROTOCOL_FILE = "file:";
  private static final String PROTOCOL_HTTP = "http:";
  private static final String PROTOCOL_SOCKET = "socket:";
  public static final int READ = 1;
  public static final int READ_WRITE = 3;
  public static final int WRITE = 2;

  public static final Connection open(String name)
    throws IOException {
    return open(name, READ_WRITE);
  }

  public static final Connection open(String name, int mode)
    throws IOException {
    Log.i("", "Connection.open:" + name);
    if (name.startsWith(PROTOCOL_FILE));
    Connection localObject = null;
    URL url = new URL(name);
    localObject = (Connection)url.getContent();
        if (name.startsWith(PROTOCOL_SOCKET)) {
          int i = name.lastIndexOf(58);
          int j = i + 1;
          int k = Integer.parseInt(name.substring(j));
          int l = "socket://".length();
          String str2 = name.substring(l, i);
//          localObject = new AndroidSocketConnection(str2, k);
          return (Connection)localObject;
        }
        Properties localProperties = System.getProperties();
        if (!(name.startsWith("p"))){
        	localProperties.put("proxySet", "true");
        	localProperties.setProperty("http.proxyHost", "10.0.0.172");
        	localProperties.setProperty("http.proxyPort", "80");
        	String str3 = name.substring(1);
//        localObject = new AndroidURLConnection(str3);
        	return localObject;
        }
    return (Connection)localObject;
  }

  public static final Connection open(String name, int mode, boolean timeouts)
    throws IOException {
    return open(name, mode);
  }

  public static final DataInputStream openDataInputStream(String paramString)
    throws IOException {
    InputStream localInputStream = openInputStream(paramString);
    return new DataInputStream(localInputStream);
  }

  public static final DataOutputStream openDataOutputStream(String paramString)
    throws IOException {
    OutputStream localOutputStream = openOutputStream(paramString);
    return new DataOutputStream(localOutputStream);
  }

  public static final InputStream openInputStream(String paramString)
    throws IOException {
    return ((InputConnection)open(paramString, READ)).openInputStream();
  }

  public static final OutputStream openOutputStream(String paramString)
    throws IOException {
    return ((OutputConnection)open(paramString, WRITE)).openOutputStream();
  }
}